﻿<html>
<head>
	<title>Space Demo Page</title>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
	<link rel="stylesheet" type="text/css" href="../styles.css"/>
	<script type="text/javascript" src="../lib/html.js"></script>
	<script type="text/javascript" src="../lib/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="../lib/raphael-min.js"></script>
	<script type="text/javascript" src="../mote.js"></script>
	<script type="text/javascript" src="space.js"></script>
	<script type="text/javascript">
		$(function(){
			$("h1").after(Html.div({style:"font-style:italic; color:#ccc;"}, 
				"Powered by MoteJS v.", Mote.version, ", Space v.", Space.version
			));
			
			var world = Mote.world($("#screen"), function(world, screen){
				var ground = world.gravity.groundPosition = screen.height;
				var width = screen.width;
				var grad = "r#008-#002";
				screen.rect(0, 0, screen.width, screen.height).attr({fill:"#002"});
				screen.circle(screen.width/2, screen.height/2, screen.width/2)
					.attr({fill:grad, "stroke-width":0});
			});
			world.trace.falling = false;
			world.trace.acceleration = false;
			//world.gravity.delay = 500;
			world.reflect = {top:0, right:0, bottom:0, left:0};
			
			var star = Mote.solid(world, [700, 400], {
				mass: 70,
				decrement: .1,
				static: true,
				template: function(screen){
					return screen.circle(0, 0, 80).attr({fill:"r(.3,.4)#aa8-#44a", stroke:"#0ac"});
				},
				surface: {sphere:80}
			});
			
			var moon = Mote.solid(world, [50, 50], {
				mass: 8,
				decrement: .1,
				static: true,
				template: function(screen){
					return screen.circle(0, 0, 30).attr({fill:"r(.3,.4)#ccc-#555", stroke:"#444"});
				},
				surface: {sphere:30}
			});
			
			/*************************************************
				ОПИСАНИЕ ГРАВИТАЦИИ
				Можно создать поле с одним центром тяготения:
				    world.gravity = new Space.Gravity(star);
				или передать массив центров тяготения:
				    world.gravity = new Space.Gravity([star, moon]);
			*************************************************/
			world.gravity = new Space.Gravity([star, moon]);
			
			Mote.solid(world, [400, 400], {
				mass: 1,
				velocity:[-.001, -.085],
				template: function(screen){
					return screen.circle(0, 0, 10).attr({fill:"r(.3,.4)#ffd-#886"});
				},
				surface: {sphere:5}
			});
			
			Mote.solid(world, [1000, 380], {
				mass: 1,
				velocity:[-.001, .092],
				template: function(screen){
					return screen.circle(0, 0, 10).attr({fill:"r(.3,.4)#dff-#77a"});
				},
				surface: {sphere:5}
			});
			
			
			
		});
	</script>
</head>
<body>
	<h1>Space Demo Page</h1>
	<div id="screen" style="border:1px solid #ccc; margin:5px; width:1400px; height:800px;"></div>
</body>
</html>